month,year = eval(input("请输入月和年:"))

isLead = (year % 4 ==0 and year % 100 !=0 ) or (year % 400 == 0)
if isLead:
    print(31 if (month == 1 or month == 3 or month == 5 or month == 7 or month == 8 or month == 10 or month == 12) else 29 if month == 2 else 30)
else:
    print(31 if (month == 1 or month == 3 or month == 5 or month == 7 or month == 8 or month == 10 or month == 12) else 28 if month == 2 else 30)